package io.renren.controller;

import io.renren.annotation.SysLog;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;
import io.renren.form.CustomGroup;
import io.renren.form.MessageGroup;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;


/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-01-20 12:55:41
 */
@RestController
@RequestMapping("api/test")
public class TestController {



    /**
     * 保存
     */
    @RequestMapping("/save")
    @SysLog("保存peak")
    public R save(@RequestBody  RequestBean requestBean){

        ValidatorUtils.validateEntity(requestBean, MessageGroup.class);


        return R.ok();
    }

}

class RequestBean {
    @NotNull(message = "用户名称不能为空", groups = {CustomGroup.class})
    String title;

    @Length(max = 26, groups = {MessageGroup.class})
    String content;

    @Range(max = 10)
    int id;


    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
}
